$viewed = Session::get('viewed_pages', []); if(!in_array($page->id, $viewed)){ $page->increment('views'); Session::push('viewed_pages', $page->id); }